function getById(data,id){
    var result=[];
    for(let i=0;i<data.length;i++){
        if(data[i].id==id){
            result.push(data[i]);
        }
        if(data[i].child){
            console.log(1);
            result.push(...getById(data[i].child,id))
        }
    }
    return result;
}
var arr=[{
    id:3,
    name:"gao"
},{
    id:4,
    name:4,
    child:[
        {
            id:3,
            name:"gao3"
        }
    ]
}]
var result=getById(arr,3);
console.log(result);
